#include <iostream>
#include <vector>

using namespace std;

int earliest_completion(int n, int m, const vector<int>& d, vector<int>& a) {
    int count = 0;
    int day = 1;  

    while (true) {
        if (count == m) 
            return day;

        if (d[day - 1] != 0) { 
            for (int i = 0; i < m; ++i) {
                if (a[i] > 0) {
                    a[i]--;
                    if (a[i] == 0) {
                        count++;
                    }
                }
            }
        }

        day++;
    }
}

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }

    vector<int> a(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }

    int result = earliest_completion(n, m, d, a);
    if (result == INT_MAX) {
        cout << -1 << endl;
    } else {
        cout << result << endl;
    }

    return 0;
}
